<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/9
 * Time: 9:49
 */

namespace app\admin\controller;

use think\Request;
class Dataptc extends common
{
    public function cqSsc(){
        $date = input('get.date');
        $where = '';
        if($date){
            $where = str_replace('-',"",$date) . '%';
        }else{
            $where = date('Ymd',time()) . '%';
        }
        $data = db('ptc')->where('expect','like',$where)->select();

        $this->assign('data',$data);
        return $this->fetch();
    }

    //手动开奖
    public function handCode(){
        if(Request::instance()->isPost()) {
            $expect = input('post.expect');
            $handcode = input('post.handcode');
            if (trim($expect) != '' && trim($handcode) != '') {
                $bool = db('ptc')->where('expect', $expect)->update(['handcode'=>$handcode]);
                if ($bool) {
                    return json_encode(['msg' => 1, 'data' => '更新成功,请刷新页面更新!']);
                } else {
                    return json_encode(['msg' => 0, 'data' => '更新失败!']);
                }
            } else {
                return json_encode(['msg' => 0, 'data' => '提交数据为空!']);
            }
        }else{
            $id = input('get.id');
            $this->assign('data',$id);
            return $this->fetch();
        }





    }


}